<script>
	import
	EventType
	from "./common/pushEventType.js"
	export default {
		onLaunch: function() {
			console.log('App Launch')
			uni.onPushMessage((res) => {
				var payload = JSON.parse(res.data.payload.text)
				console.log('onPushMessage', payload)
				if (payload.type === 1) {
					//房间内积分变化
					uni.$emit(EventType.ROOM_SCORE_CHANGE, payload)
				} else if (payload.type === 2) {
					//房间内积分变化
					uni.$emit(EventType.ROOM_MEMBER_CHANGE, payload)
				} else if (payload.type === 3) {
					//金币变化
					uni.$emit(EventType.COIN_CHANGE, payload)
					console.log("COIN_CHANGE", payload)
					var msg = ""
					if (payload.coinChangeType === 1) {
						//增加
						msg = msg + "+"
					}
					if (payload.coinChangeType === 2) {
						//减少
						msg = msg + "-"
					}
					this.$store.dispatch('ObtainUserInfo').then(result => {})
					uni.showToast({
						icon: 'none',
						title: '金币 ' + msg + payload.score
					})
				} else if (payload.type === 4) {
					//强制离开房间
					uni.$emit(EventType.LEAVE_ROOM, payload)
				} else if (payload.type === 5) {
					//强制离开房间
					uni.$emit(EventType.ROOM_CLOSE, payload)
				}

			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	.page-bg {
		background: linear-gradient(180deg, rgba(67, 116, 250, 0.7457107843137255) 0%, rgba(196, 218, 255, 1) 20%, rgba(242, 247, 255, 1) 100%);

	}
</style>